package com.ktjiaoyu.crm.controller;

import com.ktjiaoyu.crm.pojo.User;
import com.ktjiaoyu.crm.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Controller
public class UserController {

    @Autowired
    private UserService userService;


    @RequestMapping(value = "/hello/{id}")
    public String getUser(@PathVariable("id") Long usrId, Model model){
        User user = userService.getById(usrId);
        model.addAttribute("user",user);
        return "demo/hello";
    }

    @GetMapping(value = "/user/list")
    public String findUsers(String usrName,Long roleId,Model model){
        List<User> userList = userService.list();
        model.addAttribute("userList",userList);
        return "user/list";
    }


}
